<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="gv-page-container">
  <a [routerLink]="['..']" class="gv-back-link"><small><< Back to sharding tags</small></a>
  <h1>{{tag.name}}</h1>
  <div fxLayout="row">
    <div fxLayout="column" fxFlex="70">
      <form (keydown.enter)="false" (ngSubmit)="update()" #tagForm="ngForm" fxLayout="column">
        <div class="gv-form-section">
          <mat-form-field appearance="outline" floatLabel="always">
            <mat-label>ID</mat-label>
            <input matInput type="text" placeholder="ID" name="id" [(ngModel)]="tag.id" required disabled>
            <mat-hint>Sharding tag's technical id which will be set to the gateway configuration file</mat-hint>
          </mat-form-field>

          <mat-form-field appearance="outline" floatLabel="always">
            <mat-label>Name</mat-label>
            <input matInput type="text" placeholder="Name" name="name" [(ngModel)]="tag.name" required [readonly]="readonly">
            <mat-hint>Sharding tag's name</mat-hint>
          </mat-form-field>

          <mat-form-field appearance="outline" floatLabel="always">
            <mat-label>Description</mat-label>
            <input matInput type="text" placeholder="Description" name="description" [(ngModel)]="tag.description" [readonly]="readonly">
            <mat-hint>Sharding tag's description</mat-hint>
          </mat-form-field>
        </div>

        <div fxLayout="row" *hasPermission="['organization_tag_update']">
          <button mat-raised-button color="primary" [disabled]="(!tagForm.valid || tagForm.pristine)" type="submit">SAVE</button>
        </div>
      </form>

      <div class="gv-page-delete-zone" fxLayout="column" *hasPermission="['organization_tag_delete']">
        <p>This operation cannot be undone.</p>
        Sharding tag will be deleted and will not be used for gateway deployment.
        <div class="gv-page-delete-button" fxLayout="row">
          <span fxFlex></span>
          <button mat-raised-button color="warn" (click)="delete($event)">DELETE</button>
        </div>
      </div>
    </div>
    <div class="gv-page-description" fxFlex>
      <h3>Manage sharding tag</h3>
      <div class="gv-page-description-content">
        <p>
          A sharding-tag determines how security domain will be deployed across multiple AM Gateway.
        </p>
        <p>
          To make the association between security domains and Gateway instances,
          you must copy/paste the shard tag's ID to the <small style="color:grey;">gravitee.yml</small> file of the gateway instance :
        </p>

        <p style="padding: 10px; background: #f1f1f1;">
          <small>
            # Sharding tags configuration <br />
            # tags: public,private,!international
          </small>
        </p>
      </div>
    </div>
  </div>
</div>

